import React, {useState} from 'react';
import {View, Text, Button} from 'react-native';

// 父组件简化版
export default function App() {
  const [count, setCount] = useState(0);

  return (
    <View>
      <Text>当前计数: {count}</Text>
      {/* 直接传递set函数 */}
      <Counter onIncrement={() => setCount(prev => prev + 1)} />
    </View>
  );
}

// 子组件简化版
const Counter: React.FC<{onIncrement: () => void}> = ({onIncrement}) => (
  <Button title="+" onPress={onIncrement} />
);
